package com.example.littleSpider.myapplication.activity;

import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.example.littleSpider.myapplication.R;
import com.example.littleSpider.myapplication.base.BaseActivity;
import com.example.littleSpider.myapplication.fragment.gankuai.recive.IntentionFragment;
import com.example.littleSpider.myapplication.fragment.gankuai.recive.MayFragment;
import com.example.littleSpider.myapplication.fragment.gankuai.recive.NotFragment;
import com.example.littleSpider.myapplication.myInterfaces.MethodInTitle;
import com.example.littleSpider.myapplication.view.TitleView;
import com.littlespider.mylibrary.util.T;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by EDZ on 2017/12/12.
 * 我要接单界面
 */

public class RecieveActivity extends BaseActivity implements MethodInTitle {
    @BindView(R.id.tab_recieve)
    TabLayout tab_recieve;
    @BindView(R.id.vp_recieve)
    ViewPager vp_recieve;
    @BindView(R.id.title_view)
    TitleView title_view;

    FragmentManager manager;
    List<Fragment> fragmentList = new ArrayList<>();

    IntentionFragment intentionFragment = new IntentionFragment();
    MayFragment mayFragment = new MayFragment();
    NotFragment notFragment = new NotFragment();

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_recieve;
    }

    @Override
    protected void initView() {
        title_view.initMyTitle("我要接单", this);
        title_view.hideTitleTextImage();

        manager = getSupportFragmentManager();

        fragmentList.add(intentionFragment);
        fragmentList.add(mayFragment);
        fragmentList.add(notFragment);

        tab_recieve.setupWithViewPager(vp_recieve);
        vp_recieve.setAdapter(new MyPageAdapter(manager));
    }

    @Override
    protected void initData() {

    }

    class MyPageAdapter extends FragmentPagerAdapter {

        FragmentManager manager;

        public MyPageAdapter(FragmentManager fm) {
            super(fm);
            manager = fm;
        }

        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getCount() {
            return fragmentList.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            if (position == 0) {
                return "意向";
            }
            if (position == 1) {
                return "可接";
            }
            if (position == 2) {
                return "不可接";
            }
            return null;
        }

    }

    @Override
    public void setGoBack() {
        finish();
    }


    @Override
    public void onRightOne() {
        startActivity(new Intent(this, HurryupPersonalActivity.class));
    }

    @Override
    public void onRightTwo() {
        T.show(this, "你要改路线！！");
        startActivity(new Intent(this,ChangeRouteActivity.class));

    }

    @Override
    public void onTitleText() {

    }
}
